#ifndef _MOTOR_CONTROL_H
#define _MOTOR_CONTROL_H

#include "main.h"
#include "can.h"
//pid
typedef struct _PID_TypeDef
{
	float Kp;
	float Ki;
	float Kd;
	float Kf;
	float out_max;
	
	float Pout;
	float Iout;
	float Dout;
	float out;
	float last_out;
	
	float error;
	float last_error;
	float last_measure;
	

	
	
	

}PID_TypeDef;

void PID_Init(PID_TypeDef *pid,float P,float I,float D,float filter,float O_limit);
float f_abs(float num);
float PID_Calculate(PID_TypeDef *pid, int16_t measure, int16_t setpoint);
void PID_reset_K(PID_TypeDef *pid, float Kp, float Ki, float Kd);
void pid_error(PID_TypeDef *pid,motor_state*motor);
void angle_calculate(float angle,int16_t *setangle,int16_t* angle_t,float* totalangle,motor_state* motor);

#endif
